package com.wg.dome.repository;

import com.wg.dome.attribute.Attribute;
import com.wg.dome.attribute.AttributeType;
import com.wg.dome.entity.config.EquipLingShiEntity;
import com.wg.db.cache.AbstractEntityRepository;

public class EquipLingShiRepository extends AbstractEntityRepository<EquipLingShiEntity> {
    public EquipLingShiRepository() {
        super(EquipLingShiEntity.class);
    }

    public void getAttribute(short[] lsLv, Attribute attribute) {
        if (lsLv == null) {
            return;
        }

        for (int i = 0; i < lsLv.length; i++) {
            EquipLingShiEntity entity = get(lsLv[i]);
            if (entity == null) {
                return;
            }

            if (i == 0) {
                if (entity.getAtk() > 0) {
                    attribute.set(AttributeType.ATK, entity.getAtk());
                }
            } else if (i == 1) {
                if (entity.getDef() > 0) {
                    attribute.set(AttributeType.DEF, entity.getDef());
                }
            } else if (i == 2) {

                if (entity.getRgs() > 0) {
                    attribute.set(AttributeType.RGS, entity.getRgs());
                }
            } else if (i == 3) {
                if (entity.getHp() > 0) {
                    attribute.set(AttributeType.HP, entity.getHp());
                }
            }
        }
    }

    public EquipLingShiEntity getNextEntity(short lsLv) {
        return get(lsLv + 1);
    }

}
